from pyspark import SparkConf,SparkContext

conf = SparkConf().setMaster("local").setAppName("relation")
sc = SparkContext(conf = conf)



testData = sc.textFile("/child-parent.txt")
Data = testData.map(lambda line:(line.split(",")[0], line.split(",")[1]))
ImageData = Data.map(lambda line:(line[1], line[0]))

joinData = Data.join(ImageData)
newData = joinData.map(lambda line:(line[1][0],line[1][1]))
newData = newData.reduceByKey(lambda x,y:x + "," + y)

newData.saveAsTextFile("/tmp")
